package leetcode.题库.矩阵;

/**
 * description:
 *
 * @author 颜真明
 * @date 2024/3/23  6:20
 */
public class Solution240 {

    public boolean searchMatrix(int[][] matrix, int target) {
        int i = 0;
        int j = matrix[0].length-1;
        while(i<matrix.length && j>=0){
            if (target == matrix[i][j]) {
                return true;
            } else if (target > matrix[i][j]){
                i++;
            } else {
                j--;
            }
        }
        return false;
    }

}
